package com.arron.algorithm.leetcodetop100.动态规划;

import java.util.Arrays;

/**
 * 70. 爬楼梯
 */
public class 爬楼梯 {


    public int climbStairs(int n) {
        if(n==1) return 1;
        if (n==2) return 2;
        int[] a = new int[n+1];
        Arrays.fill(a,-1);
        a[0] = 0;
        a[1] = 1;
        a[2] = 2;
        return climb(a,n);
    }


    public int climb(int[] a,int n){

        if (n<=0) return 0;
        if(n==1) return 1;
        if (n==2) return 2;
        if (a[n]!=-1) return a[n];

        a[n] =climb(a,n-1) + climb(a,n-2);

        return a[n];
    }



}
